
require(["../conf/config.js"], function(){
	require(["jquery", "common"], function($,com){
		$(function(){
		 	// $("banner2-imgs>li").each((nav, index)=>{
		 	// 	nav.addEventListener("click", function(){
		 	// 		tabImg(index);
		 	// 		tabNav(index);
		 	// 	})
		 	// })
		 	let imgs =$("#banner2-imgs>li")
			//console.log(imgs)
		 	function tabImg(i) {
		 		for(let index=0;index < imgs.length;index++) {
		 			if(index != i) {
						//animate(imgs[index], {opacity : 0});
						imgs.eq(index).stop().animate({
							opacity : "0"
							},1000)
						
					}else {
						//animate(imgs[i], {opacity: 100})
						imgs.eq(index).stop().animate({
							opacity : "1"
						},1000)
					}
		 		
		 		}
		 	}
		 	/* 
		 	function tabNav(i) {
		 		for(let index in navs) {
		 			if(index != i) navs[index].className = "";
		 			else navs[index].className = "active";
		 		}
		 	}
		 	 */
		 	let currentIndex = 0;
		 	setInterval(function(){
		 		++currentIndex==2 ? currentIndex=0 : "";
		 		// if(++currentIndex==5) {
		 		// 	currentIndex = 0
		 		// } 
		 		
		 		tabImg(currentIndex);
		 		/* tabNav(currentIndex); */
		 	}, 3000)
		 	//
			$.ajax({
				url : "http://localhost:8000/static/jsons/shoppingmall.json",
				success : function(data){
					let $sixt = $(data);
					//$("#goods")
					 let $art =$("<ul id='art'>");
			
					
					 $sixt.each(function(index,items){                
						 
						 
						 
						 
						 
						console.log(items.imgsurl)//items.src
					
						 	let $li =$("<li class='message fl'> </li>");
						 	let $a =$("<a class='a1' href=''> </a>");
						 	let	$discount =$("<div class='discount'> </div>");//打折
						 	let $imglist =$("<img src ='' atl='' />");
						 	let $tradename=$("<p class='tradename'> </p>");//商品名
						 	let $pirce =$("<p class='pirce'> </p>"); //价格
						 	let $oldprice =$("<del class ='oldprice'' > </del>'");
						 	let $newprice =$("<span class ='newprice'> </span>");
						  	
						 	$("#goods").append($art);
						 	$art.append($li);
						 	$li.append($a);
						 	$a.append($discount).append($imglist).append($tradename).append($pirce).append($discount);
						 	$pirce.append($newprice).append($oldprice).append($newprice);
						 	$imglist.attr("src",items.imgsurl);//图片地址
							$a.attr("href",items.link);//引用地址
							$tradename.html(items.tradename);//商品名字
						 	$discount.html(items.discount);//打折
							
							$newprice.html(items.newprice);//新价格
							$oldprice.html(items.oldprice);//旧价格
						 	//$("img").attr({ src: "test.jpg", alt: "Test Image" });
						 
						 
						 
						 
						 
					}) 
				}
			})			
		})//onload
		
		
	})
})